<?php
/**
 * Created by PhpStorm.
 * User: wx:wenyi2048
 * Date: 2022/3/19 0019
 * Time: 14:09
 */
namespace app\common\service;

use think\Session;

class StoreTypeService extends Service
{
    protected $tableName = 'sms_mk_store_types';

    public function searchPage(&$view,$params,$isdelete = 0){

        $this->db->where('isdelete','=',$isdelete)
            ->order('sort','asc')
            ->field('*');

        $storeId = $this->checkStoreSelect(@$params['store_id']);
        if($storeId) $this->db->where('sms_stores_id','=',$storeId);

        if(@$params['name']) $this->db->where('name','like','%'.$params['name'].'%');

        $this->pageList($view,$params);
    }

    public function getStoreType($store_id){

        $storeId = $this->checkStoreSelect($store_id);
        if($storeId) $this->db->where('sms_stores_id','=',$storeId);
        return $this->db->select();
    }

    public function getStoreTypeApi($store_id){
        $this->setDb('store_types_view');
        $this->db
            ->where('sms_stores_id','=',$store_id)
            ->order('sort','asc');
        return $this->db->select();
    }
}